package org.vectrics.recruiter.struts;

import org.apache.log4j.Logger;
import org.vectrics.dataweb.WebServiceAction;
import org.vectrics.domain.Domain;
import org.vectrics.provider.BeanLocator;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.struts.Request;
import org.vectrics.system.PagePrivilege;
import org.vectrics.user.Person;



public class RecruiterPublicServlet extends RecruiterServlet {
	public static final long serialVersionUID = 34921321349342953L;
   
	private transient static Logger log = Logger.getLogger(RecruiterPublicServlet.class);
    
    protected boolean isProtected(Request request) {
    	PagePrivilege pagePriv = CoreServiceLocator.getUserAuthService().findRelevantPagePrivilege(request);
    	return(!(pagePriv == null));
    }

    protected String getDefaultUri() {
    	return("");
    }


	protected String getFormCode() {
		return("public.standard");
	}
    
	protected void afterFindAuthPerson(Request request) {
		log.debug("afterFindAuthPerson(");
	    String domainIdParam = request.getParameter("do");
	    if ((domainIdParam != null) && (domainIdParam.length() > 0)) {
	    	Long domainId = new Long(domainIdParam);
	    	Domain domain = CoreServiceLocator.getSystemService().findDomain(domainId);
	    	CoreServiceLocator.getUserAuthService().setSessionDomain(domain, request);
	    }
	}
    
    
    protected boolean isEncrypted(Request request) {
    	return(false);
    }

    public boolean userHasAccess(Request request, Person authPerson, Domain domain) {
    	boolean result = true;
    	return(result);
    }
    
    
    protected String getLoginUri(Request request) {
    	if (request.getRequestURI().startsWith("/recruit-admin/")) {
    		return("/recruit-admin/login.do");
    	} else {
    		return("/hrs-public/util/login.do");
    	}
    }
    

}